************************
*** EMPLOYMENT GROWTH **
************************
clear all 
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/

use $folder/aux_march.dta

keep if age >= 25 & age <= 59
keep if labforce == 2
drop if classwly == 10 | classwly == 13 | classwly == 14 

gen emp = empstat < 20

collapse (sum) emp (mean) logwage [pw=wtsupp], by(year metarea)
replace year = year - 1  

keep if logwage != . 
keep if year >= 1972
bysort metarea: gen num_year = _N
keep if num_year == 19

reshape wide emp logwage, i(metarea) j(year)

gen empgrowth1 = ((emp1979+emp1980) - (emp1977+emp1978)) / (emp1977+emp1978)
gen empgrowth2 = ((emp1978+emp1979) - (emp1976+emp1977)) / (emp1976+emp1977)
gen empgrowth3 = ((emp1978+emp1979) - (emp1973+emp1972)) / (emp1973+emp1972)
gen wagegrowth1 = (logwage1978+logwage1979) - (logwage1973+logwage1972)

keep metarea empgrowth* wagegrow*
decode metarea, gen(city)

preserve
gsort -empgrowth1
rename (city empgrowth1) (empgrowth_7778_7980 value_7778_7980)
keep empgrowth_7778_7980 metarea value
gen n = _n
tempfile one
save `one'
restore

preserve
gsort -empgrowth2
rename (city empgrowth2) (empgrowth_7677_7879 value_7677_7879)
keep empgrowth_7677_7879 metarea value
gen n = _n
tempfile two
save `two'
restore

preserve
gsort -empgrowth3
rename (city empgrowth3) (empgrowth_7273_7879 value_7273_7879)
keep empgrowth_7273_7879 metarea value
gen n = _n
tempfile three
save `three'
restore

preserve
gsort -wagegrowth
rename (city wagegrowth) (wagegrowth_7273_7879 wagevalue_7273_7879)
keep wagegrowth_7273_7879 metarea wagevalue_7273_7879
gen n = _n
tempfile four
save `four'
restore
*******************
*******************
*******************

clear 
use `one'
merge 1:1 _n using `two', gen(m2)
merge 1:1 _n using `three', gen(m3)
merge 1:1 _n using `four', gen(m4)

drop m* n
br

label var empgrowth_7273_7879 "Employment Growth '72-'73 vs '78-'79"
label var empgrowth_7677_7879 "Employment Growth '76-'77 vs '78-'79"
label var empgrowth_7778_7980 "Employment Growth '77-'78 vs '79-'80"
label var wagegrowth_7273_7879 "Wage Growth '77-'78 vs '79-'80"

order empgrowth_7778_7980 value_7778_7980 empgrowth_7677_7879 value_7677_7879 empgrowth_7273_7879 value_7273_7879 wagegrowth_7273_7879

replace value_7778_7980 = round(value_7778_7980, .01)
replace value_7677_7879 = round(value_7677_7879, .01)
replace value_7273_7879 = round(value_7273_7879, .01)
replace wagevalue_7273_7879 = round(wagevalue_7273_7879, .01)

export excel using "jhr_tab4", replace firstrow(varlabels)
